class SearchParser
  def initialize(calif)
    @calif = calif
  end
  
  def parse(qs)
    result = {}
    result[:unqualif] = unqualif(qs)
    result.merge(calificadores(qs))
  end
  
  protected
  
  def unqualif(str)
    str.gsub(/\s?[^\s]+:.*/, '')
  end
  
  def calificadores(str)
    result = {}
    @calif.each do |c|
      re = Regexp.new("\s?#{c}:(.*)")
      if re =~ str
        result[c.to_sym] = unqualif($1)
      end
    end
    result
  end
end
